package com.huahua.api.processor;

import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.google.common.collect.Lists;
import com.huahua.api.entity.pojo.ApiNovelBookContent;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author LoveHuahua
 * @date 2021年09月20日 10:28
 * @description believe in yourself
 */
@Component
public class NovelAdProcessor implements NovelPostProcessor {

    private final List<String> ad = Lists.newArrayList("亲,点击进去,给个好评呗,分数越高更新越快,据说给新笔趣阁打满分的最后都找到了漂亮的老婆哦!", "手机站全新改版升级地址：https://m.xbiquge.la，数据和书签与电脑站同步，无广告清新阅读！");

    @Override
    public void post(ApiNovelBookContent bookContent) {
        String content = bookContent.getContent();
        if (StringUtils.isNotEmpty(content)) {
            for (String s : ad) {
                content = content.replaceAll(s, "");
            }
            bookContent.setContent(content);
        }

    }
}
